<?php
/**
 * @Author:      zk
 * @DateTime:    18-6-22 下午5:35
 * @Description: pms 供应商的附件文件相关
 */
class PMSSupplierFiles extends Eloquent
{
    protected $table = 'supplier_files';

    /**
     * @Author: zk
     * @Date:   18-6-22 下午5:35
     * @Description:    根据供应商id(供应商合同id)获取附件列表
     * @param int $supplier_id  供应商id
     * @param int $contract_id  供应商合同id (默认为空)
     * @return array 
     */
    public static function getFilesList($supplier_id, $contract_id='') {
        $res = [];
        $select_arr = [
            'id', 'supplier_id', 'type', 'contract_id', 'file_path', 'storage_name', 'file_type', 'created_at', 'created_by',
        ];
        $list = PMSSupplierFiles::select($select_arr)
                ->where('status', 1)
                ->where('supplier_id', $supplier_id)
                ->orderBy('id');
        if($contract_id != ''){
            $list->where('contract_id', $contract_id);
        }
        $res = $list->get()->toArray();
        return $res;
    }
    
    
}